<?php


class FlyweightFactory implements Countable
{

    private $pool;

    public function get($name)
    {
        if (!isset($this->pool[$name])) {
            $this->pool[$name] = new CharaterFlyweight($name);
        }
        return $this->pool[$name];
    }
    /**
     * @return int
     */
    public function count()
    {
        return count($this->pool);
    }
}